import Sockets from '../services/socket';

export default {
  namespace: 'operation',
  state: {
    data: null,
  },
  reducers: {
    discard(state, { payload: data }) {
      return { ...state, data };
    },
  },
  effects: {
    plan({ payload: { roomNum } }) {
      Sockets.emit('discard', { roomNum });
    },
  },
  subscriptions: {
    getDate({ dispatch }) {
      Sockets.on('connect', () => {
        Sockets.on('discard', (data) => {
          dispatch({ type: 'discard', payload: data });
        });
      });
    },

  },
};
